<?php

namespace Api\Captcha\Yangbx;
use Api\Captcha\CaptchaRepository;

class YangbxRepository extends CaptchaRepository
{
    /**
     * 图形验证码信息
     * 
     * @param string $urlDomain 域名
     */
    protected function _getCaptchaInfo($urlDomain)
    {
        $captchaId = generate_uuid();
        $captchaData = [
            'captchaId'  => $captchaId,
            'captchaUrl' => $this->_getCaptcha($captchaId),
        ];
        return $captchaData;
    }
    
    /**
     * 生成图形验证码
     *
     * @param  string $captchaId 图形验证码UUID
     */
    protected function _getCaptcha($captchaId)
    {
        return $this->captcha->createById($captchaId);
    }

    /**
     * 验证图形验证码
     * @param  string $captchaCode 图形验证码
     * @param  string $captchaId   图形验证码UUID
     */
    protected function _checkCaptcha($captchaCode, $captchaId)
    {
        return $this->captcha->checkCaptchaById($captchaCode, $captchaId);
    }

}
